package com.demo.service.app.util;

import java.io.IOException;

import lombok.extern.slf4j.Slf4j;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class JsoupUtil {
    public Document read(String url){
        Document doc = null;
        try {
            //会产生IO异常
            doc = Jsoup.connect(url).get();
        } catch (IOException e) {
            log.error("地址：{}，读取异常：{}.", url,e.getMessage());
            throw new RuntimeException(e);
        }
        return doc;
    }
}
